package com.example.design.bilibili.singleton;

/**
 * 懒汉式-线程安全-同步代码块--(效率提升了，但是还是会出现冗余对象-不推荐)
 */
public class SingletonTest5 {
    public static void main(String[] args) {

    }
}

class Singleton5{

    private  static  Singleton5 instance = null;

    private Singleton5(){

    }

    public static Singleton5 getInstance(){

        if (instance == null){
            synchronized (SingletonTest5.class){
                instance = new Singleton5();
            }
        }

        return instance;
    }
}